package io.lvdaxian.handwriting.lambda;

import org.junit.Test;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 按照指定的元素进行分组
 * a = [aabb, accc]
 * b = [b111]
 * c = [c222]
 *
 * @author lihh
 */
public class GroupByTest {
  
  @Test
  public void test001() {
    Map<Character, List<String>> map = Stream.of("aabb", "accc", "b111", "c222").collect(Collectors.groupingBy(l -> l.charAt(0)));
    
    map.forEach((k, v) -> {
      System.out.println(k + " = " + v);
    });
  }
}
